package com.tjbklx1.dubbo.async;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.alibaba.dubbo.rpc.RpcContext;
import com.tjbklx1.dubbo.async.Person;
import com.tjbklx1.dubbo.async.AsyncService;

public class AsyncTest {
	
	public static void main(String[] args) throws InterruptedException, ExecutionException {
		
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "consumer.xml" });
		context.start();

		System.out.println("app run ");

		AsyncService demoService = (AsyncService) context.getBean("asyncService");
		Person p = demoService.getPerson("world");
		System.out.println(p);
		
		System.out.println("===========");
		
		Future<Person> pFuture = RpcContext.getContext().getFuture();
        p = pFuture.get();
        System.out.println(p);

	}
}
